package com.ruoyi.lnb.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lnb.domain.Testid;
import com.ruoyi.lnb.service.ITestidService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * testController
 * 
 * @author ruoyi
 * @date 2022-04-15
 */
@RestController
@RequestMapping("/lnb/testid")
public class TestidController extends BaseController
{
    @Autowired
    private ITestidService testidService;

    /**
     * 查询test列表
     */
    @PreAuthorize("@ss.hasPermi('lnb:testid:list')")
    @GetMapping("/list")
    public TableDataInfo list(Testid testid)
    {
        startPage();
        List<Testid> list = testidService.selectTestidList(testid);
        return getDataTable(list);
    }

    /**
     * 导出test列表
     */
    @PreAuthorize("@ss.hasPermi('lnb:testid:export')")
    @Log(title = "test", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Testid testid)
    {
        List<Testid> list = testidService.selectTestidList(testid);
        ExcelUtil<Testid> util = new ExcelUtil<Testid>(Testid.class);
        util.exportExcel(response, list, "test数据");
    }

    /**
     * 获取test详细信息
     */
    @PreAuthorize("@ss.hasPermi('lnb:testid:query')")
    @GetMapping(value = "/{charid}")
    public AjaxResult getInfo(@PathVariable("charid") String charid)
    {
        return AjaxResult.success(testidService.selectTestidByCharid(charid));
    }

    /**
     * 新增test
     */
    @PreAuthorize("@ss.hasPermi('lnb:testid:add')")
    @Log(title = "test", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Testid testid)
    {
        return toAjax(testidService.insertTestid(testid));
    }

    /**
     * 修改test
     */
    @PreAuthorize("@ss.hasPermi('lnb:testid:edit')")
    @Log(title = "test", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Testid testid)
    {
        return toAjax(testidService.updateTestid(testid));
    }

    /**
     * 删除test
     */
    @PreAuthorize("@ss.hasPermi('lnb:testid:remove')")
    @Log(title = "test", businessType = BusinessType.DELETE)
	@DeleteMapping("/{charids}")
    public AjaxResult remove(@PathVariable String[] charids)
    {
        return toAjax(testidService.deleteTestidByCharids(charids));
    }
}
